package com.thebox.config;

import java.util.*;

public class TheBoxConfig {
    private String database = null;
    private Map dbFormatMap = null;
    private Map connPoolParamMap = null;
    private String servletPath = null;
    private String serviceSwitch = null;
    private String serviceOffPage = null;
    private Map boxConstantMap = null;

    public TheBoxConfig() {
        dbFormatMap = new HashMap();
        connPoolParamMap = new HashMap();
        boxConstantMap = new HashMap();
    }

    public void setDatabase(String str) {
        database = str;
    }

    public String getDatabase() {
        return database;
    }

    public void setDbFormat(String n, String v) {
        //debug("n=" + n + " v=" + v);
        dbFormatMap.put(n, v);
    }

    public Map getDbFormat() {
        return dbFormatMap;
    }

    public void setConnPoolParam(String n, String v) {
        connPoolParamMap.put(n, v);
    }

    public Map getConnPoolParam() {
        return connPoolParamMap;
    }

    public void setServletPath(String str) {
        servletPath = str;
    }

    public String getServletPath() {
        return servletPath;
    }

    public void setServiceSwitch(String str) {
        serviceSwitch = str;
    }

    public String getServiceSwitch() {
        return serviceSwitch;
    }

    public void setServiceOffPage(String str) {
        serviceOffPage = str;
    }

    public String getServiceOffPage() {
        return serviceOffPage;
    }

    public void setBoxConstant(String n, String v) {
        boxConstantMap.put(n, v);
    }

    public Map getBoxConstant() {
        return boxConstantMap;
    }

    public String toString() {
        String newline = System.getProperty("line.separator");
        StringBuffer buf = new StringBuffer();

        buf.append("Box Config").append(newline);

        buf.append("Database=").append(database).append(newline).append(newline);

        buf.append( "--- DbFormat begin ---" ).append(newline);
        for (Iterator it = dbFormatMap.entrySet().iterator(); it.hasNext(); ) {
            Map.Entry en = (Map.Entry)it.next();
            buf.append("name=").append(en.getKey());
            buf.append("\t\tvalue=").append(en.getValue()).append(newline);
        }
        buf.append( "--- DbFormat end ---" ).append(newline).append(newline);

        buf.append( "--- ConnPoolParam begin ---" ).append(newline);
        for (Iterator it = connPoolParamMap.entrySet().iterator(); it.hasNext(); ) {
            Map.Entry en = (Map.Entry)it.next();
            buf.append("name=").append(en.getKey());
            buf.append("\t\tvalue=").append(en.getValue()).append(newline);
        }
        buf.append( "--- ConnPoolParam end ---" ).append(newline).append(newline);

        buf.append( "--- System Config begin ---" ).append(newline);
        buf.append("ServletPath=").append(servletPath).append(newline);
        buf.append("ServiceSwitch=").append(serviceSwitch).append(newline);
        buf.append("ServiceOffPage=").append(serviceOffPage).append(newline);
        buf.append( "--- System Config end ---" ).append(newline).append(newline);

        buf.append( "--- Box Constant begin ---" ).append(newline);
        for (Iterator it = boxConstantMap.entrySet().iterator(); it.hasNext(); ) {
            Map.Entry en = (Map.Entry)it.next();
            buf.append("name=").append(en.getKey());
            buf.append("\t\tvalue=").append(en.getValue()).append(newline);
        }
        buf.append( "--- Box Constant end ---" ).append(newline).append(newline);

        return buf.toString();
    }

    public static void debug(Object obj) {
        System.out.println("From BoxConfig: " + obj);
    }
}
